package world.snowcrystal.properties;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
@Getter
@Setter
@ConfigurationProperties("snowcrystal.auth")
public class AuthenticationProperties {

    private static final int HALF_OF_YEAR_S = 15552000;
    private static final String DEFAULT_DOMAIN = "snowcrystal.world";
    private static final  String DEFAULT_REMEMBER_ME_PARAMETER_NAME = "remember-me";
    private static final String DEFAULT_REMEMBER_ME_COOKIE_NAME = "X-Snowcrystal-Camellia";
    private static String DEFAULT_REMEMBER_ME_COOKIE_PATH = "/";
    /**
     * Cookie 的过期时间，单位为秒；默认为半年。
     *
     * @since 1.0
     */
    private Integer cookieMaxAge = HALF_OF_YEAR_S;

    private String rememberMeParameterName = DEFAULT_REMEMBER_ME_PARAMETER_NAME;

    private String rememberMeCookieName = DEFAULT_REMEMBER_ME_COOKIE_NAME;

    private String cookieDomain = DEFAULT_DOMAIN;

    /**
     * 置为 true 时，表示 Cookie 不允许被前端 Js 代码访问
     *
     * @since 1.0
     */
    private Boolean cookieHttpOnly = true;

    /**
     * 当设置为 true 时，代表浏览器只在 HTTPS 环境下才发送相关 Cookie
     *
     * @since 1.0
     */
    private Boolean cookieSecure = false;

    private String cookiePath = DEFAULT_REMEMBER_ME_COOKIE_PATH;


    /**
     * 发送注册请求后，注册相关信息被保存在 Redis 中，这里指定的是 Redis 对象的 key 名称
     * @since 1.0
     */
    private String mailVerificationQueueName = "MAIL_PENDING_VERIFICATION";

    /**
     * 邮件回执码的有效时间，默认5分钟。单位秒
     * @since 1.0
     */
    private Integer mailVerificationExpirationTime = 300;

    /**
     * 回执码的生成长度
     * @since 1.0
     */
    private Integer verificationCodeLength = 8;


    /**
     * 保存 in-place 操作令牌的 key
     * @since 1.0
     */
    private String inPlaceOperationTokenBucketName = "SNOWCRYSTAL_AUTH:IN_PLACE_TOKEN_BUCKET";

    /**
     * in-place 令牌有效期
     * @since 1.0
     */
    private Integer inPlaceOperationTokenExpirationTime = 300;

    private String inPlaceOperationTokenCookieName = "in-place-op";


    /**
     * 默认密码的最小生成长度，左闭区间
     */
    private Integer minPasswordGenerationLength = 12;

    /**
     * 默认密码的最大生成长度，右开区间
     */
    private Integer maxPasswordGenerationLength = 24;

}
